﻿#region Version Info

/* ========================================================================
* 【功能概述】
* 
* 作者：Zhai Xianwen       时间：2012-4-20 10:08:24
* 邮箱 : zhaisky@163.com
* 
* 文件名：Class1
* 版本：V1.0.1
*
* 修改者：           时间：              
* 修改说明：
* ========================================================================
*/

#endregion

using System.ServiceModel;
using System.ServiceProcess;

namespace Nms.WindowsService
{
    public class CalculatorWindowsService : ServiceBase
    {
        public ServiceHost serviceHost;

        public CalculatorWindowsService()
        {
            // Name the Windows Service
            ServiceName = "WCFWindowsServiceSample";
        }

        public static void Main1()
        {
            Run(new CalculatorWindowsService());
        }

        protected override void OnStart(string[] args)
        {
            if (serviceHost != null)
            {
                serviceHost.Close();
            }

            // Create a ServiceHost for the CalculatorService type and 
            // provide the base address.
            serviceHost = new ServiceHost(typeof(CalculatorWindowsService));

            // Open the ServiceHostBase to create listeners and start 
            // listening for messages.
            serviceHost.Open();
        }

        protected override void OnStop()
        {
            if (serviceHost != null)
            {
                serviceHost.Close();
                serviceHost = null;
            }
        }
    }
}